<?php
if(!isset($select_courier))
{
    $select_courier = true;
    $select_import = false;
}
?>
<?php
$jsScript = "$('input[name=\"import_type\"]').click(function(){
  var value = $('input[name=\"import_type\"]:checked').val();
  $.each($('input[name=\"import_type\"]'),function(){alert(this.attr('id'));});
  $('div#'+value).css('display','none');
});";
$cs = Yii::app()->clientScript;
$cs->registerScript("cargo_form#radio",$jsScript);
?>

<?php echo CHtml::errorSummary($model); ?>
<?php echo CHtml::radioButton('import_type', $select_courier,array('id'=>'courier','value'=>'courier')); ?> Courier Services
<br />
<?php echo CHtml::radioButton('import_type', $select_import,array('id'=>'shipping_line','value'=>'shipping_line')); ?> Shipping Line
<hr />
<div id="courier">
<?php echo CHtml::activeDropDownList($model, 'origin', array('ups'=>'UPS','fedex'=>'Fedex','dhl'=>'DHL','ems'=>'EMS','tnt'=>'TNT','others'=>'Others')); ?>
<?php echo CHtml::activeTextField($model, 'origin'); ?>
<?php
$this->widget('application.widgets.jui.EJqGrid',
              array(
                    'name'=>'courier',
                    'compression'=>'none',
                    'theme'=>'flick',
                    'useNavBar'=>true,
                    'useNavBar'=>'false',
                    'options'=>array(
                                     'datatype'=>'local',
                                     'colNames'=>array('Courier','AWB/Ref','Action'),
                                     'colModel'=>array(
                                                       array('name'=>'courier','index'=>'courier','width'=>120,'editable'=>true),
                                                       array('name'=>'awb','index'=>'awb','width'=>250),
                                                       array('name'=>'act','index'=>'act','width'=>50),
                                                      ),
                                     'rowNum'=>10,
                                     'rowList'=>array(10,20,30),
                                     'sortname'=>'inv_no',
                                     'viewrecords'=>true,
                                     'sortorder'=>"desc",
                                     'caption'=>"AirWay Bills / B/L",
                                     'url'=>'http://localhost/spartan/index.php/cargo/testing.html',
                                     'editurl'=>'http://localhost/spartan/index.php/cargo/testing.html',
                                     'cellEdit'=>'true',
                                    ),
                     //'callbacks'=>array('afterInsertRow'=>'function(rowid, rowdata, rowelem){$("#invoice_grid_id").val(parseInt($("#invoice_grid_id").val())+1); alert($("#invoice_grid_id").val())}',),
                   )
             );
?>
</div>
<div id="shipping_line">
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'jobno'); ?>
<?php echo CHtml::activeTextField($model,'jobno',array('size'=>20,'maxlength'=>20)); ?>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'origin'); ?>
<?php echo CHtml::activeTextField($model,'origin',array('size'=>35,'maxlength'=>35)); ?>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'freight_info'); ?>
<?php echo CHtml::activeTextField($model,'freight_info',array('size'=>50,'maxlength'=>50)); ?>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'ref'); ?>
<?php echo CHtml::activeTextField($model,'ref',array('size'=>50,'maxlength'=>50)); ?>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'eta'); ?>
<?php echo CHtml::activeTextField($model,'eta'); ?>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'desc'); ?>
<?php echo CHtml::activeTextField($model,'desc',array('size'=>60,'maxlength'=>255)); ?>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'do_id'); ?>
<?php echo CHtml::activeTextField($model,'do_id'); ?>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'carrier'); ?>
<?php echo CHtml::activeTextField($model,'carrier',array('size'=>25,'maxlength'=>25)); ?>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'shipping_line_id'); ?>
<?php echo CHtml::activeTextField($model,'shipping_line_id'); ?>
</div>
</div>